import { Request } from '@/utils/request';

/**
 * 新建标签
 * @param tagName 标签名
 */
export function createTag(tagName: string) {
  return Request.axiosInstance({
    url: '/tag/create',
    method: 'post',
    data: { tagName }
  });
}

/**
 * 修改标签
 * @param tagId 标签ID
 * @param tagName 标签名
 */
export function editTag(tagId: number, tagName: string) {
  return Request.axiosInstance({
    url: '/tag/edit',
    method: 'put',
    data: { tagId, tagName }
  });
}

/**
 * 为图片添加标签
 * @param tagId 标签ID
 * @param picId 图片ID
 * @returns
 */
export function addTag(tagId: number, picId: number) {
  return Request.axiosInstance({
    url: '/tag/add_tag',
    method: 'post',
    data: { tagId, picId }
  });
}

/**
 * 删除图片标签
 * @param tagId 标签ID
 * @param picId 图片ID
 * @returns
 */
export function delTag(tagId: number, picId: number) {
  return Request.axiosInstance({
    url: '/tag/del_tag',
    method: 'delete',
    params: { tagId, picId }
  });
}

/**
 * 销毁标签
 * @param tagId 标签ID
 * @returns
 */
export function destoryTag(tagId: number) {
  return Request.axiosInstance({
    url: '/tag/destory',
    method: 'delete',
    params: { tagId }
  });
}

/**
 * 获取标签列表
 * @returns
 */
export function getTagList() {
  return Request.axiosInstance({
    url: '/tag/list',
    method: 'get'
  });
}
